<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::Tree::Visitors::Base</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (B)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="Tree.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree.html" title="Sass::Tree (module)">Tree</a></span> &raquo; <span class='title'><a href="Visitors.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors.html" title="Sass::Tree::Visitors (module)">Visitors</a></span>
     &raquo; 
    <span class="title">Base</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::Tree::Visitors::Base 
  <span class="abstract note title">Abstract</span>
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Sass::Tree::Visitors::Base</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p class="note abstract">
  <strong>This class is abstract.</strong> 
  
</p>
<p>The abstract base class for Sass visitors. Visitors should extend this class, then implement <code>visit_*</code> methods for each node they care about (e.g. <code>visit_rule</code> for <tt><a href="RuleNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/RuleNode.html" title="Sass::Tree::RuleNode (class)">RuleNode</a></tt> or <code>visit_for</code> for <tt><a href="ForNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/ForNode.html" title="Sass::Tree::ForNode (class)">ForNode</a></tt>). These methods take the node in question as argument. They may <code>yield</code> to visit the child nodes of the current node.</p>

<p><em>Note</em>: due to the unusual nature of <tt><a href="IfNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/IfNode.html" title="Sass::Tree::IfNode (class)">Sass::Tree::IfNode</a></tt>, special care must be taken to ensure that it is properly handled. In particular, there is no built-in scaffolding for dealing with the return value of <code>@else</code> nodes.</p>

  </div>
</div>
<div class="tags">
  
</div><div id="subclasses">
  <h2>Direct Known Subclasses</h2>
  <p class="children"><a href="CheckNesting.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/CheckNesting.html" title="Sass::Tree::Visitors::CheckNesting (class)">CheckNesting</a>, <a href="Convert.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/Convert.html" title="Sass::Tree::Visitors::Convert (class)">Convert</a>, <a href="Cssize.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/Cssize.html" title="Sass::Tree::Visitors::Cssize (class)">Cssize</a>, <a href="DeepCopy.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/DeepCopy.html" title="Sass::Tree::Visitors::DeepCopy (class)">DeepCopy</a>, <a href="Extend-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/Extend.html" title="Sass::Tree::Visitors::Extend (class)">Extend</a>, <a href="Perform.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/Perform.html" title="Sass::Tree::Visitors::Perform (class)">Perform</a>, <a href="SetOptions.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/SetOptions.html" title="Sass::Tree::Visitors::SetOptions (class)">SetOptions</a>, <a href="ToCss.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Visitors/ToCss.html" title="Sass::Tree::Visitors::ToCss (class)">ToCss</a></p>
</div>

  <h2>Constant Summary</h2>
  



  <h2>Class Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#visit-class_method" title="visit (class method)">+ (Object) <strong>visit</strong>(root) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Runs the visitor on a tree.</span>
  
</li>

    
  </ul>

  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#node_name-instance_method" title="#node_name (instance method)">- (String) <strong>node_name</strong>(node) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Returns the name of a node as used in the <code>visit_*</code> method.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#visit-instance_method" title="#visit (instance method)">- (Object) <strong>visit</strong>(node) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Runs the visitor on the given node.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#visit_children-instance_method" title="#visit_children (instance method)">- (Array&lt;Object&gt;) <strong>visit_children</strong>(parent) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Visit the child nodes for a given node.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#visit_if-instance_method" title="#visit_if (instance method)">- <strong>visit_if</strong>(node) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc"><code>yield</code>s, then runs the visitor on the <code>@else</code> clause if the node has one.</span>
  
</li>

    
  </ul>


  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="visit-class_method">
  
    + (<tt>Object</tt>) <strong>visit</strong>(root) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Runs the visitor on a tree.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="Node.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Node.html" title="Sass::Tree::Node (class)">Tree::Node</a></tt>)</span>
      
      
        <span class='name'>root</span>
      
      
      
        &mdash;
        The root node of the Sass tree.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
        &mdash;
        The return value of <tt><a href="#visit-instance_method" title="Sass::Tree::Visitors::Base#visit (method)">#visit</a></tt> for the root node.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


23
24
25</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb', line 23</span>

def self.visit(root)
  new.send(:visit, root)
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="node_name-instance_method">
  
    - (<tt>String</tt>) <strong>node_name</strong>(node)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the name of a node as used in the <code>visit_*</code> method.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="Node.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Node.html" title="Sass::Tree::Node (class)">Tree::Node</a></tt>)</span>
      
      
        <span class='name'>node</span>
      
      
      
        &mdash;
        The node.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The name.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


62
63
64
65</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb', line 62</span>

def node_name(node)
  @@node_names ||= {}
  @@node_names[node.class.name] ||= node.class.name.gsub(NODE_NAME_RE, '\\1').downcase
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="visit-instance_method">
  
    - (<tt>Object</tt>) <strong>visit</strong>(node)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Runs the visitor on the given node. This can be overridden by subclasses that need to do something for each node.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="Node.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Node.html" title="Sass::Tree::Node (class)">Tree::Node</a></tt>)</span>
      
      
        <span class='name'>node</span>
      
      
      
        &mdash;
        The node to visit.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
        &mdash;
        The return value of the <code>visit_*</code> method for this node.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


34
35
36
37
38
39
40
41</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb', line 34</span>

def visit(node)
  method = "visit_#{node_name node}"
  if self.respond_to?(method, true)
    self.send(method, node) {visit_children(node)}
  else
    visit_children(node)
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="visit_children-instance_method">
  
    - (<tt>Array&lt;Object&gt;</tt>) <strong>visit_children</strong>(parent)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Visit the child nodes for a given node. This can be overridden by subclasses that need to do something with the child nodes&#8217; return values.</p>

<p>This method is run when <code>visit_*</code> methods <code>yield</code>, and its return value is returned from the <code>yield</code>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="Node.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/Node.html" title="Sass::Tree::Node (class)">Tree::Node</a></tt>)</span>
      
      
        <span class='name'>parent</span>
      
      
      
        &mdash;
        The parent node of the children to visit.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;Object&gt;</tt>)</span>
      
      
      
      
        &mdash;
        The return values of the <code>visit_*</code> methods for the children.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


52
53
54</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb', line 52</span>

def visit_children(parent)
  parent.children.map {|c| visit(c)}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="visit_if-instance_method">
  
    - <strong>visit_if</strong>(node)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p><code>yield</code>s, then runs the visitor on the <code>@else</code> clause if the node has one. This exists to ensure that the contents of the <code>@else</code> clause get visited.</p>

  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


69
70
71
72
73</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/tree/visitors/base.rb', line 69</span>

def visit_if(node)
  yield
  visit(node.else) if node.else
  node
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:49 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>